<script setup lang="ts">
import { reactive, ref } from "vue";
defineOptions({
  name: "CheckProject"
});

// 传值
const props = defineProps({
  // 1: 审核通过 2: 驳回
  optType: {
    type: Number,
    default: 1
  },
  score: {
    type: Number,
    default: 0
  },
  // 添加examineDesc属性用于接收已有的驳回内容
  examineDesc: {
    type: String,
    default: ""
  }
});
const submitForm = ref({
  score: props.score,
  examineDesc: props.examineDesc
});
const formRef = ref();
const formRules = reactive({
  score: [{ required: true, message: "清输入", trigger: "blue" }],
  examineDesc: [{ required: true, message: "清输入", trigger: "blue" }]
});

function getRef() {
  return formRef.value;
}

function getForm() {
  return submitForm.value;
}

defineExpose({ getRef, getForm });
</script>

<template>
  <div class="choose-depo">
    <el-form
      ref="formRef"
      label-position="right"
      label-width="120"
      :model="submitForm"
      :rules="formRules"
      class="w-[400px]"
    >
      <el-form-item
        v-if="props.optType == 1"
        label="获取积分"
        prop="score"
        label-width="130"
        class="mb-5"
      >
        <el-input-number
          v-model="submitForm.score"
          :min="0"
          placeholder="请输入"
          class="!w-[200px]"
        />
      </el-form-item>
      <el-form-item v-else label="驳回理由" prop="examineDesc">
        <el-input
          v-model="submitForm.examineDesc"
          placeholder="请输入"
          clearable
          type="textarea"
          :rows="4"
        />
      </el-form-item>
    </el-form>
  </div>
</template>
